<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('考勤管理列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>主合同编号：</label>
                                <input type="text" name="orderNo"/>
                            </li>
                            <li>
                                <label>主合同名称：</label>
                                <input type="text" name="name"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.addTab()" shiro:hasPermission="gcgl:kqproject:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.editTab()" shiro:hasPermission="gcgl:kqproject:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="gcgl:kqproject:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="gcgl:kqproject:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('gcgl:kqproject:edit')}]];
        var removeFlag = [[${@permission.hasPermi('gcgl:kqproject:remove')}]];
        var datas = [[${@dict.getType('gys_kqstatus')}]];
        var prefix = ctx + "gcgl/kqproject";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                detailUrl: prefix + "/detail/{id}",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "考勤管理",
                sortName: "updateat desc",
                sortOrder: "",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: '主键',
                    visible: false
                },
                {
                    field: 'gysptProjectid',
                    title: '合同ID',
                    visible: false
                },
                {
                    field: 'orderNo',
                    title: '主合同编号'
                },
                {
                    field: 'customerName',
                    title: '公司名称'
                },
                {
                    field: 'name',
                    title: '主合同名称'
                },
                {
                    field: 'jshj',
                    title: '价税合计'
                },
                {
                    field: 'jig',
                    title: '机构',
                    visible: false
                },
                {
                    field: 'piny',
                    title: '拼音码',
                    visible: false
                },
                {
                    field: 'jfriq',
                    title: '履约交付时间'
                },
                {
                    field: 'adress',
                    title: '项目地址',
                    visible: false
                },
                {
                    field: 'htype',
                    title: '合同类型',
                    visible: false
                },
                {
                    field: 'lxr',
                    title: '联系人'
                },
                {
                    field: 'qdriq',
                    title: '履约开始时间',
                    visible: false
                },
                {
                    field: 'projectManager',
                    title: '项目经理'
                },
                {
                    field: 'owner',
                    title: '成本合约'
                },
                {
                    field: 'descs',
                    title: '备注',
                    visible: false
                },
                {
                    field: 'status',
                    title: '状态',
                    formatter: function(value, row, index) {
                    	return $.table.selectDictLabel(datas, value);
                    }
                },
                {
                    field: 'createUser',
                    title: '创建人',
                    visible: false
                },
                {
                    field: 'createAt',
                    title: '创建时间',
                    visible: false
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
//                         actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="$.operate.detail(\'' + row.id + '\')"><i class="fa fa-edit"></i>二维码</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.editTab(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a> ');
                        actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="subPeople4KQ(\'' + row.id + '\')"><i class="fa fa-edit"></i>同步考勤人员</a> ');
                        actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="subKQData(\'' + row.id + '\')"><i class="fa fa-edit"></i>同步考勤数据</a> ');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        
        function subPeople4KQ(id){
        	$.ajax({
                url: "/gcgl/kqproject/subPeople4KQ/"+id, 
                type: "GET",
                success: function(response) {
                    if(response.code==0){
                    	$.table.refresh();
                    	$.modal.msgSuccess("操作成功");
                    }else{
                    	$.table.refresh();
                    	$.modal.msgSuccess("操作失败");
                    }
                },
                error: function(xhr, status, error) {
                    console.error("Error sending data", error);
                }
            });
        }
        
        function subKQData(id){
        	$.ajax({
                url: "/gcgl/kqproject/subKQData/"+id, 
                type: "GET",
                success: function(response) {
                    if(response.code==0){
                    	$.table.refresh();
                    	$.modal.msgSuccess("操作成功");
                    }else{
                    	$.table.refresh();
                    	$.modal.msgSuccess("操作失败");
                    }
                },
                error: function(xhr, status, error) {
                    console.error("Error sending data", error);
                }
            });
        }
    </script>
</body>
</html>